var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0}), (o.DailogButton = o.DialogPanel = o.SDKPlatForm = void 0);
var n = e("ASCAd");
(function (e) {
    (e[(e.Wechat = 0)] = "Wechat"),
        (e[(e.ByteBance = 1)] = "ByteBance"),
        (e[(e.QQ = 2)] = "QQ"),
        (e[(e.OV = 3)] = "OV");
})(o.SDKPlatForm || (o.SDKPlatForm = {}));
var a = (function () {
    function e() {}
    return (
        (e.Init = function (t) {
            e.SDKPlatForm = t;
        }),
        (e.getNetworkType = function (e) {
            cc.sys.platform == cc.sys.VIVO_GAME || cc.sys.platform == cc.sys.OPPO_GAME
                ? qg.getNetworkType({
                      success: function (t) {
                          cc.sys.platform === cc.sys.VIVO_GAME
                              ? (console.log("vivo network getNetworkType type:", t.type),
                                "none" != t.type && "2g" != t.type && "3g" != t.type
                                    ? e && e(!0)
                                    : (console.log("vivo 无网络连接"), e && e(!1)))
                              : cc.sys.platform === cc.sys.OPPO_GAME
                              ? (console.log("oppo network getNetworkType type:", t.networkType),
                                "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                                    ? e && e(!0)
                                    : e && e(!1))
                              : cc.sys.platform === cc.sys.HUAWEI_GAME &&
                                (console.log("getNetworkType success networkType   " + t.networkType),
                                "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                                    ? e && e(!0)
                                    : e && e(!1));
                      },
                      fail: function (t) {
                          e && e(!1), console.log("network getNetworkType   ", t.errMsg);
                      },
                      complete: function () {}
                  })
                : cc.sys.platform == cc.sys.HUAWEI_GAME
                ? hbs.getNetworkType({
                      success: function (t) {
                          console.log("getNetworkType success networkType   " + t.networkType),
                              "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                                  ? e && e(!0)
                                  : e && e(!1);
                      },
                      fail: function (t) {
                          e && e(!1), console.log("network getNetworkType   ", t.errMsg);
                      },
                      complete: function () {}
                  })
                : e && e(!0);
        }),
        (e.subscribeNetworkStatus = function (e) {
            cc.sys.platform === cc.sys.VIVO_GAME
                ? qg.subscribeNetworkStatus({
                      callback: function (t) {
                          console.log("vivo network status ,type:", t.type),
                              "none" != t.type && "2g" != t.type && "3g" != t.type ? e && e(!0) : e && e(!1);
                      }
                  })
                : cc.sys.platform === cc.sys.OPPO_GAME
                ? qg.onNetworkStatusChange(function (t) {
                      console.log("oppo network status ,isConnected:", t.isConnected, ",networkType:", t.netWorkType),
                          t.isConnected && "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                              ? e && e(!0)
                              : e && e(!1);
                  })
                : cc.sys.platform === cc.sys.HUAWEI_GAME
                ? hbs.onNetworkStatusChange(function (t) {
                      console.log(
                          "onNetworkStatusChange isConnected = " + t.isConnected + ", networkType = " + t.networkType
                      ),
                          t.isConnected && "none" != t.networkType && "2g" != t.networkType && "3g" != t.networkType
                              ? e && e(!0)
                              : e && e(!1);
                  })
                : e && e(!0);
        }),
        (e.showDialog = function (e, t, o, n, a) {
            if ((void 0 === n && (n = null), void 0 === a && (a = null), cc.sys.platform === cc.sys.VIVO_GAME)) {
                var s = new i();
                (s.title = e), (s.message = t);
                var l = new r();
                (l.text = "确定"),
                    s.buttons.push(l),
                    (s.success = function (e) {
                        console.log("dialog 成功回调：", e.index),
                            0 == e.index ? o() : 1 == e.index ? n && n() : 2 == e.index && a && a();
                    }),
                    (s.cancel = function () {
                        console.log("dialog 取消回调：");
                    }),
                    (s.fail = function (e, t) {
                        console.log("dialog 失败回调：", e, ",====code", t);
                    }),
                    cc.sys.platform === cc.sys.VIVO_GAME && qg.showDialog(s);
            } else
                cc.sys.platform == cc.sys.OPPO_GAME
                    ? qg.showModal({
                          title: e,
                          content: t,
                          success: function (e) {
                              e.confirm
                                  ? (console.log("用户点击确定"), o && o())
                                  : e.cancel && (console.log("用户点击取消"), n && n());
                          }
                      })
                    : cc.sys.platform == cc.sys.HUAWEI_GAME
                    ? qg.showModal({
                          title: e,
                          content: t,
                          success: function (e) {
                              e ? (console.log("用户点击确定"), o && o()) : (console.log("用户点击取消"), n && n());
                          }
                      })
                    : console.log("other platform show dialog");
        }),
        (e.showToast = function (e, t) {
            cc.sys.platform == cc.sys.VIVO_GAME
                ? qg.showToast({message: e, duration: t})
                : cc.sys.platform == cc.sys.OPPO_GAME && qg.showToast({title: e, icon: "success", duration: t});
        }),
        (e.vibrateShort = function () {
            n.default.getInstance().phoneVibrate("short");
        }),
        (e.vibrateLong = function () {
            n.default.getInstance().phoneVibrate("short");
        }),
        (e.onApplication = function (e) {
            cc.sys.platform === cc.sys.VIVO_GAME &&
                (qg.onShow(function () {
                    console.log("vivo game enter foreground"), e && e(!0);
                }),
                qg.onHide(function () {
                    console.log("vivo game enter background"), e && e(!1);
                }));
        }),
        (e.exitApplication = function () {
            cc.sys.platform === cc.sys.VIVO_GAME
                ? qg.exitApplication()
                : cc.sys.platform === cc.sys.OPPO_GAME
                ? qg.exitApplication({})
                : cc.sys.platform === cc.sys.HUAWEI_GAME && hbs.exitApplication({});
        }),
        e
    );
})();
o.default = a;
var i = function () {
    (this.title = "title"), (this.message = "message"), (this.buttons = []);
};
o.DialogPanel = i;
var r = function () {
    (this.text = "按钮"), (this.color = "#33dd44");
};
o.DailogButton = r;
